function t(t, e, a) {
    return e in t ? Object.defineProperty(t, e, {
        value: a,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : t[e] = a, t;
}

var e, a = require("../../utils/qqmap-wx-jssdk.js"), n = (require("/wxSearch/wxSearch.js"), 
require("../../utils/util.js")), i = getApp(), o = i.globalData.url;

new a({
    key: "BQQBZ-W6IWG-R36QO-IU64E-SWL46-2EBTD"
});

Page({
    data: {
        hidden: !0,
        domain: o,
        table_active: 0,
        dataList: [],
        onPullDownRefresh: !1,
        address: "请点击获取位置",
        pageNum: 1,
        latitude: "",
        longitude: "",
        isFromSearch: !0,
        searchLoading: !1,
        searchLoadingComplete: !1,
        swiperData: {
            imgUrls: [],
            indicatorDots: !0,
            indicatorColor: "gray",
            indicatorActiveColor: "#1776B0",
            autoplay: !0,
            interval: 5e3,
            duration: 1e3
        },
        marketIcon: [ {
            name: "特惠洗车",
            icon: "../../image/xcicon_01.png"
        }, {
            name: "美容养护",
            icon: "../../image/myicon_01.png"
        }, {
            name: "违章查询",
            icon: "../../image/wzicon_01.png"
        } ]
    },
    onConduct: function(t) {
        this.setData({
            table_active: 0,
            dataList: []
        });
    },
    location: function(t) {
        var e = this;
        wx.chooseLocation({
            success: function(t) {
                wx.setStorageSync("latitude", t.latitude), wx.setStorageSync("longitude", t.longitude);
                e.setData({
                    address: t.name
                });
            }
        }), e.fetchList(!0), wx.showNavigationBarLoading(), setTimeout(function() {
            wx.hideNavigationBarLoading(), wx.showToast({
                title: "刷新成功",
                icon: "none"
            });
        }, 1e3);
    },
    meirong: function(t) {
        wx.navigateTo({
            url: "/pages/home/meirong/meirong"
        });
    },
    youhui: function(t) {
        wx.navigateTo({
            url: "/pages/home/youhui/youhui"
        })
    },
    bindto: function(t) {
        "0" == t.currentTarget.dataset.starttime ? wx.navigateTo({
            url: "/pages/autoWash/index/index?id=" + t.currentTarget.dataset.id
        }) : wx.navigateTo({
            url: "/pages/home/detail/detail?id=" + t.currentTarget.dataset.id
        });
    },
    beginQueue: function(t) {
        var e = this, a = i.globalData.token;
        n.request(i, "wx/cust/hasPhone", "POST", {
            token: a
        }, function(a) {
            if (a.state) if (null != a.data && null != a.data.phone && "" != a.data.phone) {
                e.setData({
                    hidden: !0,
                    clickInto: 2
                }), wx.setStorageSync("UserPhone", !0);
                var n = t.currentTarget.dataset.id;
                wx.navigateTo({
                    url: "/pages/home/paidui_choise/paidui_choise?serviceType=1&shopId=" + n + "&serviceName=&service=0&selectServiceId=&home="
                });
            } else wx.setStorageSync("UserPhone", !1), e.setData({
                hidden: !1,
                clickInto: 2
            });
        }, function(t) {});
    },
    onLoad: function(t) {
        (e = this).getLocation(), e.getImage(), wx.getSetting({
            success: function(t) {
                0 == t.authSetting["scope.userLocation"] && wx.openSetting({});
            }
        }), void 0 === i.globalData.token || "" === e.data.latitude ? wx.getLocation({
            success: function(t) {
                setTimeout(function() {
                    e.fetchList();
                }, 1e3), e.setData({
                    latitude: t.latitude,
                    longitude: t.longitude
                }), i.globalData.latitude = t.latitude, i.globalData.longitude = t.longitude;
            },
            fail: function(t) {
                wx.showToast({
                    title: "请授权定位，获取门店",
                    icon: "none"
                });
            }
        }) : e.fetchList();
    },
    getLocation: function() {
        var t = this;
        wx.getLocation({
            success: function(e) {
                wx.setStorageSync("latitude", e.latitude), wx.setStorageSync("longitude", e.longitude);
                t.setData({
                    latitude: e.latitude,
                    longitude: e.longitude
                }), i.globalData.latitude = e.latitude, i.globalData.longitude = e.longitude, t.addressConvert();
            },
            fail: function(t) {
                wx.showToast({
                    title: "请授权定位，获取门店",
                    icon: "none"
                });
            }
        });
    },
    addressConvert: function() {
        var t = new a({
            key: "BQQBZ-W6IWG-R36QO-IU64E-SWL46-2EBTD"
        }), e = this, n = wx.getStorageSync("latitude"), o = wx.getStorageSync("longitude");
        t.reverseGeocoder({
            location: {
                latitude: n,
                longitude: o
            },
            success: function(t) {
                e.setData({
                    address: t.result.address
                }), i.globalData.address = t.result.address;
            }
        });
    },
    fetchList: function(t) {
        var e = this, a = this.data.pageNum, o = wx.getStorageSync("latitude"), s = wx.getStorageSync("longitude");
        if ("" == o || void 0 === o) var o = e.data.latitude, s = e.data.longitude;
        var c = i.globalData.token;
        n.request(i, "wx/biz/nearbyShops", "POST", {
            latitude: o,
            longitude: s,
            pageNum: a,
            token: c
        }, function(a) {
            if (a.state) if (1 == e.data.onPullDownRefresh && e.success(), e.data.dataList.length > 3) if (a.data.length > 0) {
                var n = !(a.data.length > 2);
                e.setData({
                    dataList: t ? a.data : e.data.dataList.concat(a.data),
                    searchLoading: n,
                    searchLoadingComplete: !0
                });
            } else e.setData({
                searchLoadingComplete: !0,
                searchLoading: !1
            }); else a.data.length > 0 && e.setData({
                dataList: t ? a.data : e.data.dataList.concat(a.data),
                searchLoadingComplete: !0,
                searchLoading: !1
            }); else console.log(a);
        }, function(t) {});
    },
    onReachBottom: function() {
        var t = this;
        this.setData({
            pageNum: t.data.pageNum + 1
        }), this.fetchList();
    },
    onPullDownRefresh: function() {
        var e = this;
        e.setData(t({}, "swiperData.imgUrls", [])), e.getImage(), e.setData({
            pageNum: 1,
            onPullDownRefresh: !0
        }), e.fetchList(!0), wx.showNavigationBarLoading(), setTimeout(function() {
            wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
        }, 1500);
    },
    onShow: function() {
        var t = this;
        i.globalData.token;
        t.getLocation(), t.fetchList(!0), wx.getSetting({
            success: function(e) {
                0 == e.authSetting["scope.userLocation"] && (wx.showToast({
                    title: "请授权位置权限",
                    icon: "none"
                }), wx.openSetting({
                    success: function(e) {
                        t.getLocation(), setTimeout(function() {
                            t.fetchList();
                        }, 1e3), t.data.dataList && wx.showToast({
                            title: "请重新刷新界面",
                            icon: "none"
                        });
                    }
                }));
            }
        });
    },
    onHide: function() {
        e.fetchList(!0);
    },
    wxSearchTab: function() {
        wx.navigateTo({
            url: "/pages/home/youhui/search/search?types=1"
        });
    },
    swipclick: function() {
        wx.showToast({
            title: "优惠活动关注门店",
            icon: "none"
        });
    },
    vipClick: function() {
        wx.showToast({
            title: "会员办理业务待续。。",
            icon: "none"
        });
    },
    success: function() {
        wx.showToast({
            title: "刷新成功",
            icon: "none"
        });
    },
    maintain: function() {
        wx.showToast({
            title: "维修",
            icon: "none"
        });
    },
    zhuche: function(t) {
            wx.navigateTo({
                url: "/pages/home/zhuche/shopIntro"
            });
    },
    selfWashing: function() {
        wx.navigateTo({
            url: "/pages/autoWash/index/index"
        });
    },
    confirm: function(t) {
        var e = this, a = wx.getStorageSync("encryptedDataPhone");
        "" == a || null == a || void 0 === a ? wx.showToast({
            title: "请先绑定手机",
            icon: "none"
        }) : (e.setData({
            hidden: !0
        }), e.beginQueue());
    },
    cancelPhone: function() {
        this.setData({
            hidden: !0
        });
    },
    getPhoneNumber: function(t) {
        var e = this;
        t.currentTarget.dataset.id;
        n.registerPhone(t.detail.encryptedData, t.detail.iv, i, function(t) {
            wx.showToast({
                title: "授权成功"
            });
        }), e.setData({
            hidden: !0
        });
    },
    getImage: function() {
        var e = this, a = [];
        n.request(i, "wx/sys/getAdvUrl", "GET", {}, function(n) {
            for (var i in n.data) a.push(n.data[i].url);
            e.setData(t({}, "swiperData.imgUrls", a));
        }, function(t) {});
    },
    getPhoneRegister: function() {
        var t = this, e = i.globalData.token;
        n.request(i, "wx/cust/hasPhone", "POST", {
            token: e
        }, function(e) {
            e.state && (null != e.data && null != e.data.phone && "" != e.data.phone ? (t.setData({
                hidden: !0
            }), wx.setStorageSync("UserPhone", !0)) : (t.setData({
                hidden: !1
            }), wx.setStorageSync("UserPhone", !1)));
        });
    },
    autoWash: function(t) {
        wx.navigateTo({
            url: "/pages/autoWash/shopNav/index?id=" + t.currentTarget.dataset.id + "&lat=" + t.currentTarget.dataset.lat + "&lng=" + t.currentTarget.dataset.lgt + "&shopName=" + t.currentTarget.dataset.shopname + "&shopAddr=" + t.currentTarget.dataset.shopaddr + "&click=0"
        });
    },
    onShareAppMessage: function(t) {}
});